package com.kfm.mvn.service;

import com.kfm.mvn.dao.FileDao;
import com.kfm.mvn.model.File;

import java.sql.SQLException;
import java.util.List;

/**
 * 文件服务类
 */
public class FileService {

    private FileDao fileDao = new FileDao();

    public List<File> listFiles() {
        try {
            return fileDao.selectAll();
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }

    public void addFile(File file){
        int save = fileDao.save(file);
        if (save == 0){
            throw new RuntimeException("保存文件失败");
        }
    }
}
